<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1">
    <!-- Google Chrome Frame也可以让IE用上Chrome的引擎: -->
    <meta name="renderer" content="webkit">
    <!--国产浏览器高速模式-->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>作业管理系统</title>

    <!-- 公共样式 开始 -->
    <link rel="stylesheet" type="text/css" href="../../css/base.css">
    <link rel="stylesheet" type="text/css" href="../../css/iconfont.css">
    <script type="text/javascript" src="../../framework/jquery-1.11.3.min.js"></script>
    <link rel="stylesheet" type="text/css" href="../../layui/css/layui.css">
    <script type="text/javascript" src="../../layui/layui.js"></script>
    <!-- 滚动条插件 -->
    <link rel="stylesheet" type="text/css" href="../../css/jquery.mCustomScrollbar.css">
    <script src="../../framework/jquery-ui-1.10.4.min.js"></script>
    <script src="../../framework/jquery.mousewheel.min.js"></script>
    <script src="../../framework/jquery.mCustomScrollbar.min.js"></script>
    <script src="../../framework/cframe.js"></script><!-- 仅供所有子页面使用 -->
    <!-- 公共样式 结束 -->
    <script type="text/javascript" src="../../framework/frameAll.js"></script>
</head>
<body>
<div class="cBody">
    <!-- 表格 -->
    <table class="layui-table-cell layui-hide" id="demo" lay-filter="test"></table>
    <!-- layUI 分页模块 -->
    <div id="pages"></div>
</div>
<script>
    layui.use('table', function () {
        var table = layui.table,
            content = "";
        $.ajax({
            type: "get",
            url: "/UserServlet.do",
            data: {action: "getUser"},
            dataType: "Json",
            success: function (data) {
                if (data.user) {
                    content = data.user.className;
                    if (content) {
                        table.render({
                            elem: '#demo',
                            height: "full-100",
                            method: "get",
                            request: {
                                pageName: 'pageNo',//页码的参数名称，默认：page
                                limitName: 'pageSize' //每页数据量的参数名，默认：limit
                            },
                            where: {
                                action: "page",
                                content: content
                            },
                            url: '/StudentServlet.do',//数据接口
                            page: true, //开启分页
                            limits: [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],
                            cellMinWidth: 100,
                            cols: [[
                                {title: '序号', type: 'numbers'},
                                {field: 'no', title: '学号', sort: true},
                                {field: 'name', title: '学生姓名'},
                                {field: 'className', title: '班级名称'},
                                {field: 'age', title: '年龄', width: 80, align: 'center', sort: true},
                                {field: 'email', title: '邮箱'},
                                {field: 'phone', title: '手机号码', align: 'center', width: 120}
                            ]]
                        });
                    }else{
                        noMsg("您没有班级！");
                    }
                }
            },
            error:function () {
                noMsg("获取数据失败");
            }
        });
    });
</script>
</body>

</html>
